﻿CREATE FUNCTION dbo.NLin_NSITypeOfAct
	(
	@ID int
	)
RETURNS int
AS
	BEGIN
	DECLARE @linksCount int
	
	SELECT @linksCount = COUNT(ID) FROM CONTRACT WHERE NSI_TYPE_OF_ACTIVITY_ID = @ID
	
	SELECT @linksCount = @linksCount + COUNT(ID) FROM INVOICE_IN WHERE NSI_TYPE_OF_ACTIVITY_ID = @ID
	
	RETURN @linksCount
	END